package com.zb777.shuzhilingxi.controller;


import com.zb777.shuzhilingxi.Pojo.dto.MistakenQuestionListDTO;
import com.zb777.shuzhilingxi.Pojo.entity.MistakenQuestionList;
import com.zb777.shuzhilingxi.result.Result;
import com.zb777.shuzhilingxi.service.IMistakenQuestionListService;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2025-07-11
 */
@RestController
@RequestMapping("mistaken_question_service")
@Tag(name = "错题本接口")
@Slf4j
public class MistakenQuestionListController {

    @Autowired
    private IMistakenQuestionListService mistakenQuestionService;


    @Schema(description = "创建错题列表")
    @PostMapping("/list/create")
    public Result saveMistakenQuestionlist(@RequestBody MistakenQuestionListDTO mistakenQuestionListDTO) {
        log.info("创建错题列表:{}",mistakenQuestionListDTO);
        return mistakenQuestionService.saveMistakenQuestionlist(mistakenQuestionListDTO);
    }
    @GetMapping("/list/all")
    @Schema(description = "创建错题列表")
    public Result<List<MistakenQuestionList>> selectMistakenQuestionlist() {
        log.info("获取错题列表:{}");
        return mistakenQuestionService.selectMistakenQuestionlist();
    }
    @PutMapping("/list/delete/{ListId}")
    @Schema(description = "创建错题列表")
    public Result deleteMistakenQuestionlist(@PathVariable(value = "ListId") Integer ListId) {
        log.info("删除错题列表:{}",ListId);
        return mistakenQuestionService.deleteMistakenQuestionlist(ListId);
    }
    @PutMapping("/list/edit/{ListId}")
    @Schema(description = "创建错题列表")
    public Result updateMistakenQuestionlist(
            @PathVariable(value = "ListId") Integer ListId
            ,@RequestBody MistakenQuestionListDTO mistakenQuestionListDTO) {
        log.info("编辑错题列表:{}",ListId);
        return mistakenQuestionService.updateMistakenQuestionlist(ListId, mistakenQuestionListDTO);
    }
}
